home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 21
/
Aminet 21 (1997)(GTI - Schatztruhe)[!][Oct 1997].iso
/
Aminet
/
comm
/
www
/
HTMLDate.lha
/
HTMLDate.ged
next >
Wrap
Text File
|
1997-07-22
|
5KB
|
161 lines
/* Update the revision date in HTML docs using GoldED V4+ ©1997 Roy E Brown
Email: roy@ebrown.demon.co.uk
$VER: HTMLDate.ged V1.5 (22.7.97)
Some revisions (marked) and suggestions by Gregor B. Rosenauer aka Rosso
HTMLDate.ged will update the revision date of your HTML pages.
HTMLDate.ged searches for a user-defined text string, deletes the existing
date and enters the current date into the text.
HTMLDate.ged is configured to look for a text string (default "Last revised:"
- without the quotes). It then assumes that this string is followed by
either a 3 or 4 word date string, as in the 2 examples below.
Your date string can be in one of two styles:
(1) Last revised on: 31 March 1997
(2) Last revised: Monday, 31 March 1997
The date itself can be surrounded by any number of text style tags i.e
'<B><I>31 March 1997</I></B>'. Thanks to Rosso for implementing multiple
HTML style tags.
Define the string to search for in the variable 'Str' below.
Define the date style in the 'Style' variable below.
You should set the GoldED default date style (Extras/Options global/gui) to
one of the following -
Style 1 %e %B %Y
Style 2 %A, %e %B %Y (The comma is optional)
This will then insert the date in the correct format.
*/
Str="Last revised:" /* Enter your required search string - can be any length,
within reason - it doesn't need to be case sensitive -
thanks again to Rosso for the idea */
Style=1 /* Set the style of your date string (see above) */
/* **************************************************************************
Please do not change anything below here, unless you know what you're doing
of course.
*************************************************************************** */
Options Results /* enable return codes */
If (Left(Address(),6) ~="GOLDED") Then /* not started by GoldEd? */
Address 'GOLDED.1'
'LOCK CURRENT RELEASE=4' /* lock GUI, gain access */
If (RC ~= 0) Then Exit
Options Failat 6 /* ignore warnings */
Signal On Syntax /* ensure clean exit */
Vers="HTMLDate V1.5 ©1997 Roy E Brown"
If Style<1|Style>2 Then
Do
'REQUEST TITLE="'Vers'"
BODY="The Style variable is|outside the permitted range"
BUTTON="Oops"'
'UNLOCK'
Exit
End
If Style=1 Then
StyleLen=2 /* 31 March 1997 */
Else
StyleLen=3 /* Monday, 31 March 1997 */
/* Let's find the string and jump to it */
'FIND STRING="'Str'" FIRST WORDS=0 QUIET'
'QUERY BUFFER VAR=BUFF'
If Index(Upper(BUFF),Upper(Str))=0 Then
Do
'REQUEST TITLE="'Vers'"
BODY="There doesn''t appear to be|a revision date on this page"
BUTTON="Oops"'
'UNLOCK'
Exit
End
/* Move cursor beyond text string and back one place */
Do I=1 to Words(Str)
'NEXT'
End
'LEFT'
/* Let's see what the ASCII code of the character under the cursor is */
'QUERY CODE' /* '<' is ASCII Code 60 */
Do While (RESULT=60) /* skip ALL HTML-tags */
'RIGHT'; 'NEXT'; 'LEFT'; /* move to next word */
'QUERY CODE' /* revised by Rosso, 6.7.97 */
End
'RIGHT'; /* go to start of next word */
/* Save date insertion point - needed if 'EXCLUDE CURSOR' is ON.
Revised by Rosso, 6.7.97 */
'PING SLOT=0'
/* Mark the start of the block, move to the last character of the date,
mark the end of the block and delete the existing date. */
'MARK SET COLUMN BEGIN'
Do I=1 to StyleLen
'NEXT'
End
'ENDWORD'
/* Is 'EXCLUDE CURSOR IN BLOCK' on or off? - suggestion by Rosso */
'QUERY EXCLUDE VAR=CURSE'
If CURSE="TRUE" Then 'RIGHT' /* EXCLUDE CURSOR is ON therefore */
/* move one character to the right */
'MARK SET END'
'DELETE BLOCK'
/* Recall date insertion point - needed if 'EXCLUDE CURSOR' is ON.
Revised by Rosso, 6.7.97 */
'PONG SLOT=0'
/* Get the current date and insert into the document */
'QUERY DATE'
'TEXT T "'Strip(RESULT,'B')'"' /* remove leading and trailing blanks */
/* added - Rosso, 6.7.97 */
'UNLOCK' /* VERY important: unlock GUI */
Exit
SYNTAX:
Say "Sorry, error line" SIGL ":" Errortext(RC) ":-("
'UNLOCK'
Exit